package testcase.app;


import org.json.JSONArray;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import api.app.ActivityPopup;
import common.Host;
import common.TestData;

/**
 * 帮忙医获取广告信息ActivityPopup接口测试用例
 * @author lipeng
 *
 */
public class TestActivityPopup
{
	/**
	 * 帮忙医获取广告信息ActivityPopup接口测试环境数据驱动
	 * @return
	 * @throws Exception
	 */
    @DataProvider(name = "Test")
    public static String[][] testActivityPopupDataProvider() throws Exception{
          Host.setup("Test");
          TestData td = new TestData("app/TestActivityPopup.xml");
          return td.getParam();
    }
    
    @Test(dataProvider="Test",groups={"Test"})
    public void testActivityPopupTestCase(String casename,String token)throws Exception{
    	//调用接口并将接口返回的数据转换成json格式
 	   String result = ActivityPopup.get(token);
 	   JSONArray jsonResult;
 	   if(result==null || result.isEmpty()){
 		   jsonResult = null;
 	   }
 	   else {
 		   jsonResult = new JSONArray(result);
 	}
    	//设置检查点
    	switch (casename)
		{
			case "Success":
				if (result.equals("[]")) {
					Assert.assertEquals(result, "[]");
				}else {
					Assert.assertEquals(jsonResult.getJSONObject(0).getString("ImgUrl").isEmpty(),false);		
					break;
				}
			default:
				break;
		}
    }
    
}
